#include <stdio.h>
#include <math.h>

int main(void) {
    int c;
    while (1) {
        int letters[26] = {0};
        int max = 0;
        while (c = getchar(), c != EOF && c != '\n') {
            int count = ++letters[c - 'A'];
            max = count > max ? count : max;
        }
        int num = max;
        int run = 1;
        if (num == 0) {
            break;
        }
        while (run) {
            int checked = 0;
            for (int x = 0; x < 26; x++) {
                while (letters[x] % num != 0) {
                    num--;
                    checked = 1;
                    break;
                }
                if (checked) {
                    break;
                }
            }
            if (checked == 0) {
                break;
            }
        }
        if (num != 0) {
            for (int x = 0; x < 26; x++) {
                letters[x] /= num;
            }
            max /= num;
        }
        for (int y = max; y > 0; y--) {
            int spaces = 0;
            for (int x = 0; x < 26; x++) {
                if (letters[x] != 0) {
                    if (letters[x] >= y) {
                        for (int sp = 0; sp < spaces; sp++) {
                            putchar(' ');
                        }
                        spaces = 0;
                        putchar('*');
                    } else {
                        spaces++;
                    }
                }
            }
            putchar('\n');
        }
        for (int x = 0; x < 26; x++) {
            if (letters[x] != 0) {
                putchar('A' + x);
            }
        }
        if (max != 0) {
            putchar('\n');
            putchar('\n');
        }
        if (c == EOF) {
            break;
        }
    }
    return 0;
}
